//////////////////////////////////////////////
// File				:	InputDevice.h
//
// Author			:	Nick Faletra (NF)
//
// Date Created		:	12/20/2013
//////////////////////////////////////////////
#ifndef _INPUTDEVICE_H_
#define _INPUTDEVICE_H_

#ifndef DIRECTINPUT_VERSION
	#define DIRECTINPUT_VERSION 0x800
#endif
#include <dinput.h>

#pragma comment(lib, "dinput8.lib")
#pragma comment(lib, "dxguid.lib")

#define BUFFER_SIZE 10

#ifndef DIERRBOX
#define DIERRBOX(hWnd, errorText) { MessageBox(hWnd, errorText, "Input Error", MB_OK | MB_ICONEXCLAMATION); }
#endif

class IInputDevice
{
public:
	virtual ~IInputDevice() = 0 {};

	virtual bool ReadDevice() = 0;
	virtual bool ReadBufferedDevice() = 0;

	virtual bool Acquire() = 0;
	virtual bool Unacquire() = 0;
};

class CInputDevice : public IInputDevice
{
protected:
	IDirectInputDevice8* m_pDevice;

	DIDEVICEOBJECTDATA	m_didod[BUFFER_SIZE];
	DWORD				m_dwBufferElements;

	void ClearBufferedData();

public:
	CInputDevice();
	virtual ~CInputDevice();

	virtual bool ReadBufferedDevice();

	virtual bool Acquire();
	virtual bool Unacquire();
};

#endif // _INPUTDEVICE_H_